06 / 17

What is the Load Factor? How does it trigger a Rehash/Resize?

Load Factor and Resizing

javascript
  1. 1

    A lower load factor generally means fewer collisions but more memory usage.

  2. 2

    A higher load factor improves memory efficiency but can increase lookup cost.

  3. 3

    Resizing usually allocates a larger table.

  4. 4

    Existing entries must be rehashed because bucket indexes depend on table capacity.

  5. 5

    A resize operation itself can take O(n).

  6. 6

    Over many insertions, resizing can still preserve amortized O(1) insertion.

Difficulty: 3/10

Follow-up Questions

  • Why must entries be rehashed after resizing?
  • How does resizing affect amortized complexity?
  • What load factor would you choose and why?